Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-5691] Extract crypto to separate crate #402

Merged
merged 40 commits into from
Jan 15, 2024
Merged

[PM-5691] Extract crypto to separate crate #402

merged 40 commits into from
Jan 15, 2024

Conversation

Hinton
Copy link
Member

@Hinton Hinton commented Dec 5, 2023

Type of change

- [ ] Bug fix
- [ ] New feature development
- [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

We should make an effort to break up the large bitwarden crate into smaller more isolated crates. This extracts the cryptographic primitives into a crate, which better isolates them and may improve compile time slightly. We should continue to extract further areas.

Code changes

  • crates/bitwarden/src/crypto: Move everything to crates/bitwarden-crypto.

Screenshots

Before you submit

  • Please add unit tests where it makes sense to do so (encouraged but not required)

@bitwarden-bot
Copy link

bitwarden-bot commented Dec 6, 2023

Logo
Checkmarx One – Scan Summary & Details4bca6312-994f-4f30-ac86-77879465b0e1

No New Or Fixed Issues Found

Hinton and others added 4 commits December 7, 2023 11:09
# Conflicts:
#	crates/bitwarden-crypto/src/enc_string.rs
#	crates/bitwarden-crypto/src/rsa.rs
#	crates/bitwarden/Cargo.toml
#	crates/bitwarden/src/auth/login/access_token.rs
#	crates/bitwarden/src/auth/login/api_key.rs
#	crates/bitwarden/src/auth/login/password.rs
#	crates/bitwarden/src/client/client.rs
#	crates/bitwarden/src/client/encryption_settings.rs
#	crates/bitwarden/src/crypto/enc_string.rs
#	crates/bitwarden/src/crypto/enc_string/symmetric.rs
#	crates/bitwarden/src/crypto/mod.rs
#	crates/bitwarden/src/mobile/crypto.rs
#	crates/bitwarden/src/tool/generators/client_generator.rs
#	crates/bitwarden/src/tool/generators/passphrase.rs
#	crates/bitwarden/src/uniffi_support.rs
#	crates/bitwarden/src/vault/cipher/attachment.rs
#	crates/bitwarden/src/vault/cipher/card.rs
#	crates/bitwarden/src/vault/cipher/cipher.rs
#	crates/bitwarden/src/vault/cipher/field.rs
#	crates/bitwarden/src/vault/cipher/identity.rs
#	crates/bitwarden/src/vault/cipher/login.rs
#	crates/bitwarden/src/vault/cipher/secure_note.rs
#	crates/bitwarden/src/vault/collection.rs
#	crates/bitwarden/src/vault/folder.rs
#	crates/bitwarden/src/vault/password_history.rs
#	crates/bitwarden/src/vault/send.rs
@Hinton Hinton changed the title Experiment with using a separate crate for crypto Extract crypto to separate crate Jan 4, 2024
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Attention: 101 lines in your changes are missing coverage. Please review.

Comparison is base (4c91270) 50.04% compared to head (f9dca85) 50.15%.
Report is 6 commits behind head on main.

❗ Current head f9dca85 differs from pull request most recent head cf2a3b6. Consider uploading reports for the commit cf2a3b6 to get more accurate results

Files Patch % Lines
crates/bitwarden/src/auth/login/mod.rs 0.00% 24 Missing ⚠️
crates/bitwarden-crypto/src/uniffi_support.rs 0.00% 14 Missing ⚠️
crates/bitwarden-crypto/src/encryptable.rs 38.46% 8 Missing ⚠️
crates/bitwarden/src/vault/cipher/cipher.rs 0.00% 7 Missing ⚠️
crates/bitwarden/src/vault/password_history.rs 0.00% 5 Missing ⚠️
crates/bitwarden/src/vault/cipher/login.rs 0.00% 4 Missing ⚠️
crates/bitwarden/src/vault/send.rs 63.63% 4 Missing ⚠️
crates/bitwarden-crypto/src/error.rs 0.00% 3 Missing ⚠️
...rates/bitwarden-crypto/src/enc_string/symmetric.rs 75.00% 2 Missing ⚠️
crates/bitwarden-crypto/src/fingerprint.rs 66.66% 2 Missing ⚠️
... and 16 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #402      +/-   ##
==========================================
+ Coverage   50.04%   50.15%   +0.10%     
==========================================
  Files         155      157       +2     
  Lines        7467     7493      +26     
==========================================
+ Hits         3737     3758      +21     
- Misses       3730     3735       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Hinton Hinton marked this pull request as ready for review January 8, 2024 09:20
Hinton added 13 commits January 8, 2024 11:03
# Conflicts:
#	crates/bitwarden/src/platform/generate_fingerprint.rs
# Conflicts:
#	crates/bitwarden/src/error.rs
#	crates/bitwarden/src/vault/send.rs
# Conflicts:
#	crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs
#	crates/bitwarden/src/crypto/mod.rs
#	crates/bitwarden/src/vault/send.rs
# Conflicts:
#	crates/bitwarden/src/auth/password.rs
# Conflicts:
#	crates/bitwarden-crypto/src/enc_string/asymmetric.rs
#	crates/bitwarden-crypto/src/enc_string/symmetric.rs
#	crates/bitwarden-crypto/src/keys/master_key.rs
#	crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs
#	crates/bitwarden-crypto/src/rsa.rs
#	crates/bitwarden/src/auth/login/access_token.rs
#	crates/bitwarden/src/client/access_token.rs
#	crates/bitwarden/src/platform/generate_fingerprint.rs
# Conflicts:
#	crates/bitwarden-crypto/src/enc_string/symmetric.rs
#	crates/bitwarden-crypto/src/keys/master_key.rs
#	crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs
#	crates/bitwarden/src/crypto/mod.rs
@Hinton Hinton requested a review from a team as a code owner January 11, 2024 12:34
@Hinton Hinton requested a review from dani-garcia January 11, 2024 15:43
dani-garcia
dani-garcia previously approved these changes Jan 11, 2024
@Hinton Hinton changed the title Extract crypto to separate crate [PM-5691] Extract crypto to separate crate Jan 12, 2024
# Conflicts:
#	crates/bitwarden-crypto/src/asymmetric_crypto_key.rs
#	crates/bitwarden-crypto/src/enc_string/asymmetric.rs
#	crates/bitwarden-crypto/src/encryptable.rs
#	crates/bitwarden-crypto/src/keys/key_encryptable.rs
#	crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs
#	crates/bitwarden/src/client/encryption_settings.rs
#	crates/bitwarden/src/crypto/mod.rs
#	crates/bitwarden/src/vault/cipher/attachment.rs
#	crates/bitwarden/src/vault/cipher/card.rs
#	crates/bitwarden/src/vault/cipher/cipher.rs
#	crates/bitwarden/src/vault/cipher/field.rs
#	crates/bitwarden/src/vault/cipher/identity.rs
#	crates/bitwarden/src/vault/cipher/local_data.rs
#	crates/bitwarden/src/vault/cipher/login.rs
#	crates/bitwarden/src/vault/cipher/secure_note.rs
#	crates/bitwarden/src/vault/collection.rs
#	crates/bitwarden/src/vault/folder.rs
#	crates/bitwarden/src/vault/password_history.rs
#	crates/bitwarden/src/vault/send.rs
@Hinton Hinton requested a review from dani-garcia January 15, 2024 10:25
dani-garcia
dani-garcia previously approved these changes Jan 15, 2024
Copy link
Contributor

@michalchecinski michalchecinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hinton Hinton requested a review from dani-garcia January 15, 2024 14:59
@Hinton Hinton merged commit d2cb4f9 into main Jan 15, 2024
43 checks passed
@Hinton Hinton deleted the ps/crypto-crate branch January 15, 2024 15:13
Hinton added a commit that referenced this pull request Jan 19, 2024
Continuation on #402. This PR extracts the generators to their own crate
to establish clear boundaries between the code. There is still some
logic in the client to expose generators that we may want to revisit.

Also extracts explicit errors for the different generators for better
error handling downstream when/if desired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants